From 6f3aa59eecdba2e2c86ed372b1c4745d93a0b50d Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 12 Oct 2014 17:33:23 +0000 Subject: [PATCH] clean up gpx reader fix element handling. Note that the fix element values are required to be in lower case by the schema. --- gpsbabel/gpx.cc | 22 +++++++++------------- gpsbabel/testo.d/gpx.test | 6 +++--- gpsbabel/testo.d/gtm.test | 2 -- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index c2d2331a1..8e436ccf5 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -1118,24 +1118,21 @@ gpx_end(const QString& el) case tt_wpttype_sat: wpt_tmp->sat = cdatastr.toDouble(); break; - case tt_wpttype_fix: { - // FIXME: this code seems to rely on atoi() parsing 3d and 2d as 3 and 2 - // which toInt() doesn't do. - //wpt_tmp->fix = (fix_type)(cdatastr.toInt() - 1); - wpt_tmp->fix = (fix_type)(atoi(CSTR(cdatastr)) - 1); - } - if (wpt_tmp->fix < fix_2d) { - if ((cdatastr.compare("none", Qt::CaseInsensitive)) == 0) { + case tt_wpttype_fix: + if (cdatastr == QLatin1String("none")) { wpt_tmp->fix = fix_none; - } else if ((cdatastr.compare("dgps", Qt::CaseInsensitive)) == 0) { + } else if (cdatastr == QLatin1String("2d")) { + wpt_tmp->fix = fix_2d; + } else if (cdatastr == QLatin1String("3d")) { + wpt_tmp->fix = fix_3d; + } else if (cdatastr == QLatin1String("dgps")) { wpt_tmp->fix = fix_dgps; - } else if ((cdatastr.compare("pps", Qt::CaseInsensitive)) == 0) { + } else if (cdatastr == QLatin1String("pps")) { wpt_tmp->fix = fix_pps; } else { wpt_tmp->fix = fix_unknown; } - } - break; + break; case tt_wpttype_url: link_->url_ = cdatastr; break; @@ -1905,7 +1902,6 @@ gpx_exit(void) gpx_version = NULL; } - /* FIXME: is clear necessary or desirable? */ gpx_namespace_attribute.clear(); if (gpx_global) { diff --git a/gpsbabel/testo.d/gpx.test b/gpsbabel/testo.d/gpx.test index 962446750..c9174de7f 100644 --- a/gpsbabel/testo.d/gpx.test +++ b/gpsbabel/testo.d/gpx.test @@ -1,10 +1,10 @@ # GPX -rm -f ${TMPDIR}/gl.gpx ${TMPDIR}/gpx.gpx +rm -f ${TMPDIR}/gl.gpx ${TMPDIR}/gpx.wpt gpsbabel -i geo -f ${REFERENCE}/../geocaching.loc -o gpsman -F ${TMPDIR}/gm.gm -o gpsutil -F ${TMPDIR}/gu.wpt gpsbabel -i geo -f ${REFERENCE}/../geocaching.loc -o gpx -F ${TMPDIR}/gl.gpx -gpsbabel -i gpx -f ${TMPDIR}/gl.gpx -o gpsutil -F ${TMPDIR}/gpx.gpx -compare ${TMPDIR}/gpx.gpx ${TMPDIR}/gu.wpt +gpsbabel -i gpx -f ${TMPDIR}/gl.gpx -o gpsutil -F ${TMPDIR}/gpx.wpt +compare ${TMPDIR}/gpx.wpt ${TMPDIR}/gu.wpt rm -f ${TMPDIR}/gtrnctr_power.gpx gpsbabel -i gtrnctr -f ${REFERENCE}/track/gtrnctr_power.tcx -o gpx,garminextensions=1 -F ${TMPDIR}/gtrnctr_power.gpx diff --git a/gpsbabel/testo.d/gtm.test b/gpsbabel/testo.d/gtm.test index b85500885..6289c6c36 100644 --- a/gpsbabel/testo.d/gtm.test +++ b/gpsbabel/testo.d/gtm.test @@ -1,6 +1,5 @@ # GTM -rm -f ${TMPDIR}/gl.gpx ${TMPDIR}/gpx.gpx gpsbabel -i gtm -f ${REFERENCE}/sample.gtm -o gpx -F ${TMPDIR}/gtm1.gpx gpsbabel -i gpx -f ${TMPDIR}/gtm1.gpx -o gtm -F ${TMPDIR}/gtm.gtm gpsbabel -i gtm -f ${TMPDIR}/gtm.gtm -o gpx -F ${TMPDIR}/gtm2.gpx @@ -10,7 +9,6 @@ bincompare ${TMPDIR}/gtm.gtm ${REFERENCE}/sample.gtm # GTM compressed files # ... do the same as above but with gzipped gtm files # -rm -f ${TMPDIR}/gl.gpx ${TMPDIR}/gpx.gpx gpsbabel -i gtm -f ${REFERENCE}/sample.gtm.gz -o gpx -F ${TMPDIR}/gtm1.gpx gpsbabel -i gpx -f ${TMPDIR}/gtm1.gpx -o gtm -F ${TMPDIR}/gtm.gtm.gz gpsbabel -i gtm -f ${TMPDIR}/gtm.gtm.gz -o gpx -F ${TMPDIR}/gtm2.gpx -- 2.30.2